﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>文章管理</title>
    <link rel="stylesheet" href="/static/assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="/static/assets/module/admin.css?v=318"/>
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script type="text/javascript" charset="utf-8" src="/static/Baidu/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/static/Baidu/ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="/static/Baidu/lang/zh-cn/zh-cn.js"></script>
</head>

<body>

<a href="/index/Admin/wenzhang"><button class="layui-btn">&emsp;返回&emsp;
    </button>
    </a>
        <input name="id" id="id" type="hidden"/>
        <div class="layui-input-item"  >
            <label class="layui-form-label">分类:</label>
            <select name="explain_type" id="fenlei" lay-verType="tips" style="layui-form model-form">
                <option value="">选择</option>
                <option value="1">注册隐私</option>
                <option value="2">隐私政策</option>
                <option value="3">阅读审核</option>
                <option value="4">关于我们</option>
                 <option value="5">帮助中心</option>
            </select>

        </div>

        <div class="layui-form-item" style="width:85%;">
            <label class="layui-form-label">标题:</label>
            <div class="layui-input-block">
                <input name="title" id="title"placeholder="标题" class="layui-input"
                       lay-verType="tips" lay-verify="required" value=""/>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">内容:</label>
            <div class="layui-input-block" style="z-index:1;">
                <textarea  id="demo" cols="60" rows="4" style="display: none" class="textArea"></textarea>
                <script id="editor" type="text/plain"  style="width:90%;height:200px;">

                </script>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="formStepSubmit2">&emsp;保存&emsp;
                </button>
            </div>
        </div>
<!-- js部分 -->
<script type="text/javascript" src="/static/assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="/static/assets/js/common.js?v=318"></script>

<script>
    function tiaozhuan(){
        window.location.href="/index/Admin/wenzhang"
    }

    layui.use(['layer', 'form', 'laydate','jquery', 'upload'], function () {

        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;
        var upload = layui.upload;
        var ue;
        var id = "<?php echo $_GET['id']; ?>";
        if(id != 0){
            $.post('/index/Admin/getArticle', {
                id:id
            }, function (res) {
                var data = res.data;

                $("#fenlei").val(data.explain_type);
                $("#title").val(data.title);
                $("#demo").text(data.content);
                $("#editor").html(data.content)
                $("#id").val(data.id);
                ue = UE.getEditor('editor');

            }, 'json');
        }else{
            ue = UE.getEditor('editor');
        }
        $("#formStepSubmit2").click(function(){
            var loadindexx = layer.load(2);
            var explain_type = $("#fenlei").val();
            var title= $("#title").val();
            var demo = ue.getContent();

            var id = $("#id").val();
            $.post('/index/Admin/addWenzhang', {
                explain_type: explain_type,
                demo:demo,
                title:title,
                id:id
            }, function (res) {
                layer.close(loadindexx);
                if (res.code === 1) {
                    layer.msg(res.msg, {icon: 1});
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }, 'json');

        })
    });

</script>
</body>
</html>
